package src.main.java.org.annotation;

import org.junit.Test;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Arrays;

/*
* 注解的解析
* */
public class AnnotationTest3 {
    @Test
    public void parseClass(){
        Class<Demo> demoClass = Demo.class;
        //解析类上的注解
        if(demoClass.isAnnotationPresent(MyTest3.class)){
            MyTest3 myTest3 = (MyTest3) demoClass.getDeclaredAnnotation(MyTest3.class);
            System.out.println(myTest3.value());
            System.out.println(myTest3.aaa());
            System.out.println(Arrays.toString(myTest3.bbb()));
        }
    }
    @Test
    public void parseMethod() throws Exception {
        Class<Demo> demoClass = Demo.class;
        Method test1 = demoClass.getDeclaredMethod("test1");

        //解析类上的注解
        if(test1.isAnnotationPresent(MyTest3.class)){
            MyTest3 myTest3 = (MyTest3) demoClass.getDeclaredAnnotation(MyTest3.class);
            System.out.println(myTest3.value());
            System.out.println(myTest3.aaa());
            System.out.println(Arrays.toString(myTest3.bbb()));
        }
    }
}
